
<?php

function getRssFeeds(){
$errorLevel = error_reporting(); 
error_reporting(0);
$property = 'properties/rssFeeds.xml';

$arraySources = simplexml_load_file($property);


foreach ($arraySources as $source){
		$rss = $source->rssRemote;
		//$valid = validateFeed($rss);	
		//if($valid){
		if( $rss_feed = simplexml_load_file($rss)) {
			$rssLocalTarget =  $source->rssLocal;
			$feed = file_get_contents($rss);
			if ($feed === FALSE){
				
			}
			
			
			else{
			file_put_contents($rssLocalTarget, "");
				if(strpos(feed, "ISO-8859-1") !== FALSE){
					$feed = str_replace("ISO-8859-1", "UTF-8", $feed);				
					$feed = utf8_encode($feed);					
					$feed = html_entity_decode($feed,ENT_NOQUOTES,"UTF-8");
					$feed = str_replace("&amp;ldquo;", '"', $feed);
					$feed = str_replace("&amp;rdquo;", '"',$feed);
					file_put_contents($rssLocalTarget, $feed);
				}else{
					$feed = str_replace("&amp;ldquo;", '"', $feed);
					$feed = str_replace("&amp;rdquo;", '"',$feed);
					file_put_contents($rssLocalTarget, $feed);
				}
			}
		}
		else{
					//nos quedamos con la version anterior valida
		}
}
	
error_reporting($errorLevel);

}
?>